﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using IDAL.A;
using Model.A;

namespace DAL.A
{
    public class AUnion:BaseRepository_DT<AUnionInfo>,IAUnion 
    {
        #region 静态变量部分
        private const string PARM_AUNION_PACKAGEPRODUCTSN = "@PackageProductSN";
        private const string PARM_AUNION_PCBASN = "@PCBASN";
        private const string PARM_AUNION_PRODUCTTYPEID = "@ProductTypeID";
        private const string PARM_AUNION_RECORDTIME = "@RecordTime";
        private const string PARM_AUNION_USERID = "@UserID";

        private const string PARM_AUNION_SN = "@SN";
        #endregion

        #region 数据检索部分
        public IList<AUnionInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public AUnionInfo LoadEntity<T1>(T1 sn)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = sn;
            return ExcuteSqlToGetEntity("AUnion_selectbySN", parm);
        }

        public IList<AUnionInfo> AUnion_GetbyDT(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = dt1;
            parms[1].Value = dt2;
            return ExcuteSqlToGetEntities("AUnion_selectbyDT", parms);
        }
        #endregion


        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override AUnionInfo GetEntityRecord(SqlDataReader rdr)
        {
            AUnionInfo pro = new AUnionInfo(rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(),rdr.GetValue(2).ToString(),rdr.GetDateTime(3),rdr.GetValue(4).ToString());
            return pro;
        }

        public override AUnionInfo GetEntityRecord()
        {
            AUnionInfo pro = new AUnionInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "AUnion_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_AUNION_SN, SqlDbType.NVarChar, 50);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_AUNION_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_AUNION_PCBASN, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_AUNION_PRODUCTTYPEID, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_AUNION_RECORDTIME, SqlDbType.DateTime,8),
					new SqlParameter(PARM_AUNION_USERID, SqlDbType.NVarChar, 50),
                };
            return parms;
        }

        public override void SetParameters(AUnionInfo mo, params SqlParameter[] Parms)
        {
            Parms[0].Value = mo.PackageProductSN;
            Parms[1].Value = mo.PCBASN;
            Parms[2].Value = mo.ProductTypeID;
            Parms[3].Value = mo.RecordTime;
            Parms[4].Value = mo.UserID;
        }
        #endregion
    }
}
